package com.wdb007.venus.quartz;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.wdb007.venus.svc.facade.BookgridService;
import com.wdb007.venus.svc.facade.OrderService;
import com.wdb007.venus.svc.facade.WxAPPMessagePushService;
import com.wdb007.venus.svc.facade.exception.BizException;

@Component
public class RentBookChargeScheduler {

	private final Logger logger = LoggerFactory.getLogger(RentBookChargeScheduler.class);  
	
	@Autowired
	private OrderService orderService;
	
	@Autowired
	private BookgridService bookgridService;
	
	@Autowired
	private WxAPPMessagePushService wxAPPMessagePushService;
    @Scheduled(cron="0 0 0 * * ?")	//每天凌晨执行
//	@Scheduled(cron="0 0/5 * * * ?")
    public void charge() {
    	try {
			orderService.bookCharge();
			wxAPPMessagePushService.sendVipExpireTimeNotice();
		} catch (BizException e) {
			logger.error(e.getMessage(), e);
		}
    }
    
    @Scheduled(cron="0/5 * * * * ?")
    public void bookGridStatusReportCron() {
    	try {
    		bookgridService.bookGridStatusReportCron();
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
		}
    }
    
    @Scheduled(cron="0 0 1 * * ?")
    public void readStatistics() {
    		logger.info("readStatistics start....");
    		try {
    			orderService.readStatistics();
    		}catch (Exception e) {
    			logger.error(e.getMessage(), e);
    		}
    }
}
